package org.jsola.contract.helper;

import org.jsola.common.SafeKit;
import org.jsola.contract.dto.CompanyContractShowAddDTO;
import org.jsola.contract.dto.CompanyContractShowUpdateDTO;
import org.jsola.contract.entity.CompanyContractShowDO;
import org.jsola.contract.query.CompanyContractShowQuery;
import org.jsola.contract.service.ICompanyContractShowService;
import org.jsola.contract.vo.CompanyContractShowVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;

import java.util.List;

import static org.jsola.contract.core.AbstractTest.SITE_ID;



/**
 * 合同员工签署后是否展示
 *
 * @author JanusMix
 */
@Component
public class CompanyContractShowTestHelper extends BaseTestHelper {
    
    @Autowired
    private ICompanyContractShowService companyContractShowService;

    /**
     * 生成add测试数据
     * @return CompanyContractShowAddDTO
     */
    public CompanyContractShowAddDTO getCompanyContractShowAddDTO(){
        CompanyContractShowAddDTO companyContractShowAddDTO = new CompanyContractShowAddDTO();
        companyContractShowAddDTO.setCompanyId(getRandomValue("varchar",32));
        companyContractShowAddDTO.setIsShow(SafeKit.getBoolean(getRandomValue("tinyint",1)));
        return companyContractShowAddDTO;
    }


    /**
     * 生成update测试数据
     * @return CompanyContractShowUpdateDTO
     */
    public CompanyContractShowUpdateDTO getCompanyContractShowUpdateDTO(CompanyContractShowVO companyContractShowVO){
        return companyContractShowService.selectDOById(companyContractShowVO.getId(), SITE_ID).to(CompanyContractShowUpdateDTO.class);
    }

    /**
     * 生成查询数据
     * @return CompanyContractShowQuery
     */
    public CompanyContractShowQuery getCompanyContractShowQuery() {
        CompanyContractShowQuery companyContractShowQuery = new CompanyContractShowQuery();
        List<CompanyContractShowDO> companyContractShowDOList = companyContractShowService.list(new CompanyContractShowDO(),SITE_ID);
        if (!CollectionUtils.isEmpty(companyContractShowDOList)) {
            CompanyContractShowDO companyContractShowDO = companyContractShowDOList.get(0);
            companyContractShowQuery = companyContractShowDO.to(CompanyContractShowQuery.class);
        }
        return companyContractShowQuery;
    }

    /**
     * 保存示例
     * @return CompanyContractShowVO
     */
    public CompanyContractShowVO saveCompanyContractShowExample(){
        CompanyContractShowAddDTO addDTO = this.getCompanyContractShowAddDTO();
        CompanyContractShowVO companyContractShowVO = companyContractShowService.save(addDTO,buildTokenUser());
        return companyContractShowVO;
    }


}

